import React, { useEffect, useState } from 'react'
import styles from './index.less'
import { useDispatch, useHistory, useSelector } from 'dva'
import WantbuyCard from '../../components/wantbuyCard'
import ReturnIndex from "../../components/returnIndex"
function Index() {

  const dispatch = useDispatch()
  const {
    wantbuyList,
    userInfo
  } = useSelector(({ index }) => index)
  useEffect(() => {
    console.log(wantbuyList)
    dispatch({
      type: 'index/apiGetWantbuyList',
      payload: {
        creatorId:  userInfo?.user?.id
      }
    })
  }, [])
  // console.log(wantbuyList, 'wantbuyList')
  return (
    <div className={styles.page}>
      <ReturnIndex/>
      <div className={styles.wantbuy}>
      {
        wantbuyList && wantbuyList.map((item, index) => {
          return <WantbuyCard
            key={index}
            id={item.id}
            item={item}
          ></WantbuyCard>
        })
      }
      </div>
    </div>
  )
}
export default Index
